<div class="clear mainbox-title-container">

	<div><?php
	$user_type = @$_GET['user_type'] ? $_GET['user_type'] : @$model->user_type;
	if ( !empty($user_type) ) {
		switch ($user_type) {
			case 'F':
				echo CHtml::link('&laquo; '.t('Back').':&nbsp;'.t('Cộng tác viên'), array('/user/manageCTV'), array('class' => 'back-link strong'));
				break;
		}
	} ?></div>

	<h1 class="mainbox-title">
		<?php if ( $model->user_id ) {
			echo t('Edit CTV Information');
		} else {
			echo t('Add CTV');
		} ?></h1>

	<div class="mainbox-title-bg">&nbsp;</div>
</div>

<div class="extra-tools">
	<?php if ( $model->user_id ) : ?>
		<?php echo CHtml::link(t('Add ctv'), array('user/addCTV'), array('class' => 'tool-link')) ?>
	<?php endif; ?>
</div>

<?php Yii::app()->clientScript->registerScriptFile(bu() .'/js/tabs.js'); ?>

<?php
$tabs = array(
	'general' => t('General Information'),
);
$tabs['ctv_content'] = t('Assign Books');

$this->renderPartial('//common/tabs_header', array(
	'tabs' => $tabs,
	'active_tab' => getParam('selected_section') ? getParam('selected_section') : 'general',
)) ?>

<?php $form = $this->beginWidget('CActiveForm', array(
	'id' => 'user_form',
	'enableClientValidation' => true,
	'focus' => array($model, 'email'),
	'htmlOptions' => array(
		'class' => 'form',
	),
)); ?>

<div class="cm-tabs-content">

	<input type="hidden" name="selected_section" id="selected_section" value="general">

	<?php echo CHtml::errorSummary($model); ?>

	<div id="content_general" style="display: block;">
		<fieldset>
			<h2 class="subheader"><?php echo t('Account Information') ?></h2>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'email'); ?>
				<?php echo $form->textField($model, 'email', array('size' => 32, 'maxlength' => 128, 'class' => 'input-text')); ?>
				<?php echo $form->error($model, 'email'); ?>
			</div>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'password1'); ?>
				<?php echo $form->passwordField($model, 'password1', array('size' => 32, 'maxlength' => 32, 'class' => 'input-text', 'autocomplete' => 'off')); ?>
				<?php echo $form->error($model, 'password1'); ?>
			</div>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'password2'); ?>
				<?php echo $form->passwordField($model, 'password2', array('size' => 32, 'maxlength' => 32, 'class' => 'input-text', 'autocomplete' => 'off')); ?>
				<?php echo $form->error($model, 'password2'); ?>
			</div>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'status'); ?>
				<div class="select-field">
					<?php echo $form->radioButtonList($model, 'status', array(
						'A' => t('Active'),
						'D' => t('Unactive'),
					), array(
						'separator' => '&nbsp;&nbsp;',
						'class' => 'radio',
					)); ?>
				</div>
			</div>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'user_type'); ?>
				<?php echo $form->dropDownList($model, 'user_type', User::getUserTypes()) ?>
				<?php echo $form->error($model, 'user_type'); ?>
			</div>

		</fieldset>

		<fieldset>
			<h2 class="subheader"><?php echo t('Contact Information') ?></h2>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'name'); ?>
				<?php echo $form->textField($model, 'name', array('size' => 32, 'maxlength' => 256, 'class' => 'input-text')); ?>
				<?php echo $form->error($model, 'name'); ?>
			</div>

			<div class="form-field">
				<?php echo $form->labelEx($model, 'phone'); ?>
				<?php echo $form->textField($model, 'phone', array('size' => 32, 'maxlength' => 32, 'class' => 'input-text')); ?>
				<?php echo $form->error($model, 'phone'); ?>
			</div>

		</fieldset>

	</div>

	<?php if ( !empty($model->user_id) && ($model->user_type == 'F' || (isset($_GET['user_type']) && $_GET['user_type'] == 'F')) ) : ?>
	<div id="content_ctv_content" class="" style="display: none;">
		<fieldset>
			<h2 class="subheader"><?php echo t('Assign Books') ?></h2>
			<?php
			if ( $model->user_id ) {
				$this->renderPartial('//picker/products_picker', array(
					'object_id' => $model->user_id,
					'item_name' => 'CTVBooks',
					'items' => $model->ctvProducts,
				));
			} ?>

		</fieldset>
	</div>
	<?php endif; ?>

	<div class="buttons-container buttons-bg cm-toggle-button">
		<span class="submit-button cm-button-main ">
			<?php echo CHtml::submitButton($model->isNewRecord ? t('Create') : t('Save')); ?>
		</span>
		&nbsp;<?php echo t('or') ?>&nbsp;&nbsp;
		<?php echo CHtml::link(t('Cancel'), array('/user/manageCTV'), array('class' => 'underlined tool-link')) ?>
	</div>

</div>

<?php $this->endWidget(); ?>